<?php
/**
* 这个是首页的模板
*/
class ModelClass extends GetLoad
{
	
	public function Getinformation(){

		$reluse=$this->SQLquery("select * from information order by information_id desc");
		
		//var_dump($reluse);
		return $reluse;

	}
	public function Getname($name_id){
				$reluse=$this->SQLquery("SELECT name from name WHERE name_id='".$name_id."'");
				
				return $reluse[0]["name"];


	}

	public function Getneirong($neirong){
				$reluse=mb_substr($neirong,0,301,'utf-8');
					
				return $reluse."……";


	}

	public function jiaru(){

		$reluse=$this->SQLquery("SELECT name FROM name order by name_id desc limit 0,10");
		return $reluse;

	}

	public function jianliclass($data){

		
		$this->SQLcun("INSERT INTO class (name,zhucema) VALUES('".$_POST['mingcheng']."','".hash("crc32",date("d-Y-M-h:i:sa"))."')");
		$reluse=$this->SQLquery("select MAX(class_id) from class");
		$this->SQLcun("INSERT INTO laoshi (laoshi_id,kemu,class) VALUES(".$data['name_id'].",'".$_POST['kemu']."',".$reluse[0]['MAX(class_id)'].")");
		header("Location: ./index.php?route=Controller/jiaoshi/ControllerJiaoshi/index"); 


	}

	public function chazhaozhucema($zhucema){

		$reluse=$this->SQLquery("SELECT * from class where zhucema='".$zhucema."'");
		if(!isset($reluse)){
			echo "您的注册码有误";
			die;
		}

		//var_dump($reluse);
		return $reluse[0]['class_id'];


	}

	public function jiarubanji($data){
		$a=$this->chazhaozhucema($_POST['id']);
		$v=$this->SQLcun("INSERT INTO laoshi (laoshi_id,kemu,class) VALUES (".$data['name_id'].",'".$_POST['kemu']."',".$a.")");
	
			echo "您已成功加入班级";
	
	}

	public function getxiaozu($data){

		$reluse=$this->SQLquery("SELECT * from xiaozu_zhuce WHERE laoshi='".$data['name_id']."'");

		return $reluse;

	}

	public function tianjiachengyuan($data){

		$this->SQLcun("INSERT INTO xiaozu (xiaozu_id,zuhao,chengyuan_id) VALUES(".$_POST["xiaozu_id"].",".$_POST['zuhao'].",".$_POST["chengyuan_id"].")");

		header("Location: ./index.php?route=Controller/jiaoshi/ControllerJiaoshi/getxiaozu"); 


	}

	public function shangchuxiaozuchengyuan($chengyuan_id){

		$this->SQLcun("DELETE from xiaozu where id =".$chengyuan_id);


	}

	public function xinjanxiaozu($data){

		$this->SQLcun("INSERT INTO xiaozu_zhuce (class,laoshi) VALUES (".$data[0].",".$data[1].")");

		header("Location: ./index.php?route=Controller/jiaoshi/ControllerJiaoshi/getxiaozu"); 
	}

	public function getclass($laoshi_id){

		$reluse = $this->SQLquery("SELECT * from laoshi where laoshi_id=".$laoshi_id);


		return $reluse;

	}






}